package com.gljx.web.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gljx.web.Entity.TrainType;
import com.gljx.web.dao.TrainTypeMapper;
import com.gljx.web.service.TrainTypeService;

@Service
@Transactional
public class TrainTypeServiceImpl implements TrainTypeService {

	@Autowired
	private TrainTypeMapper trainTypeMapper;
	
	/**
	 * 查询培训类型
	 */
	@Override
	public List<TrainType> selTrainType() {
		// TODO Auto-generated method stub
		return trainTypeMapper.selTrainType();
	}

	/**
	 * 根据名称查找培训类型
	 */
	@Override
	public List<TrainType> selTrainTypeByName(String name) {
		// TODO Auto-generated method stub
		return trainTypeMapper.selTrainTypeByName(name);
	}
	/**
	 * 根据FID查找培训类型
	 */
	@Override
	public TrainType selTrainTypeById(String string) {
		// TODO Auto-generated method stub
		return trainTypeMapper.selTrainTypeById(string);
	}

	/**
	 * 实现根据公司id查询
	 */
	@Override
	public List<TrainType> queryTrainTypeByCompanyId(String companyId) {
		// TODO Auto-generated method stub
		return trainTypeMapper.selectTrainTypeByCompanyId(companyId);
	}

	/**
	 * 实现根据公司id和名称查询
	 */
	@Override
	public List<TrainType> queryTrainTypeByCompanyIdAndFnameL2(String companyId, String fnameL2) {
		// TODO Auto-generated method stub
		Map<String, String> map = new HashMap<String, String>();
		map.put("companyId", companyId);
		map.put("fnameL2", fnameL2);
		return trainTypeMapper.selectTrainTypeByCompanyIdAndFnameL2(map);
	}

	/**
	 * 实现查询上一个编码
	 */
	@Override
	public String selectFnumber(String companyId) {
		// TODO Auto-generated method stub
		return trainTypeMapper.selectFnumber(companyId);
	}

	/**
	 * 实现添加
	 */
	@Override
	public void addTrainType(TrainType trainType) {
		// TODO Auto-generated method stub
		trainTypeMapper.insertSelective(trainType);
	}

	/**
	 * 实现修改
	 */
	@Override
	public void modifyTrainType(TrainType trainType) {
		// TODO Auto-generated method stub
		trainTypeMapper.updateByPrimaryKeySelective(trainType);
	}

	/**
	 * 实现根据fid删除
	 */
	@Override
	public void deleteTrainTypeByFid(String fid) {
		// TODO Auto-generated method stub
		trainTypeMapper.deleteByPrimaryKey(fid);
	}

}
